<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="hr">
<head>
    <title>Administracija</title>
</head>
<body>
    <?php if (Debug::isOn()): ?><pre style="border: 1px solid red; padding: 10px;"><?php Debug::_display('users'); ?></pre> <?php endif; ?>
    <h1>Administracija - korisnici</h1>

    <?php
    if (!empty($v['errors']))
    {
        foreach ($v['errors'] as $error)
            echo '<p style="color: red;">' . $error . '</p>';
    }
    ?>

    <form action="/admin/user/save" method="post">
        <table>
            <tr>
                <td>E-mail:</td>
                <td><input type="text" name="admin_email" value="<?php if (isset($v['email'])) echo $v['email']; ?>" /></td>
            </tr>
            <tr>
                <td>Zaporka:</td>
                <td><input type="password" name="admin_password" value="" /></td>
            </tr>
            <tr>
                <td>Ponoviti zaporku:</td>
                <td><input type="password" name="admin_password_check" value="" /></td>
            </tr>
            <tr>
                <td>Ime:</td>
                <td><input type="text" name="first_name" value="<?php if (isset($v['first_name'])) echo $v['first_name']; ?>" /></td>
            </tr>
            <tr>
                <td>Prezime:</td>
                <td><input type="text" name="last_name" value="<?php if (isset($v['last_name'])) echo $v['last_name']; ?>" /></td>
            </tr>
            <tr>
                <td>Vrsta korisnika:</td>
                <td>
                    <select name="user_level">
                        <option value="">-- Nedefinirano --</option>
                        <?php

                        foreach ($v['possible_user_levels'] as $level)
                        {
                            echo '<option value="' . $level['id'] . '" ' . (($level['id'] == $v['user_level']) ? 'selected="selected"' : '') . '>' . $level['name'] . '</option>';
                        }

                        ?>
                    </select>
                </td>
            </tr>
            <tr>
                <td>Ban:</td>
                <td>
                    <select name="on_line">
                        <option value="1" <?php echo ($v['on_line'] == 1) ? 'selected="selected"' : ''; ?>>Nije aktivan</option>
                        <option value="0" <?php echo ($v['on_line'] == 0) ? 'selected="selected"' : ''; ?>>Aktivan</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <input type="hidden" name="id" value="<?php echo (!empty($v['id'])) ? $v['id'] : 0; ?>" />
                    <input name="save" value="Save" type="submit" />
                </td>
            </tr>
        </table>
    </form>
</body>
</html>
